package org.dfzt.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @Description: 判断是否使用webscoket容器，如果使用的是war包的方式不装配bean，使用方式@Conditional(WarAndJarWebscoketAutoWired.class)
 * @author: cuiyf
 * @Date: 2020/8/18 9:18
 * @Version: 1.0
 */
public class WarAbdJarWebSocketAutoWired implements Condition {
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        Environment env = conditionContext.getEnvironment();
        String style = env.getProperty("package.style");
//        String active = env.getProperty("spring.profiles.active");
        return ("jar".equals(style));
    }
}
